package net.esj.basic.core.engine.tools.test.inst;

import java.lang.annotation.Annotation;

import net.esj.basic.core.engine.tools.test.ClassTest;

public class ClassAnnotatedWith implements ClassTest {

	
	private Class<? extends Annotation> annotation;

    /** Construts an AnnotatedWith test for the specified annotation type. */
    public ClassAnnotatedWith(Class<? extends Annotation> annotation) { this.annotation = annotation; }

    /** Returns true if the type is annotated with the class provided to the constructor. */
    public boolean matches(Class type) {
        return type != null && type.isAnnotationPresent(annotation);
    }
	@Override
	public boolean test(Class o) {
		return o != null && o.isAnnotationPresent(annotation);
	}

}
